package cn.johnyu.jmsdemo;

import javax.jms.Connection;
import javax.jms.ConnectionFactory;
import javax.jms.Destination;
import javax.jms.MessageConsumer;
import javax.jms.MessageProducer;
import javax.jms.Session;
import javax.jms.TextMessage;

import org.apache.activemq.ActiveMQConnectionFactory;
import org.apache.activemq.command.ActiveMQQueue;


public class PtpConsumer {

	public static void main(String[] args) throws Exception{
		ConnectionFactory factory=new ActiveMQConnectionFactory("tcp://127.0.0.1:61616");
		Destination queue=new ActiveMQQueue("john01");
		Connection con=factory.createConnection();
		con.start();
		Session sen=con.createSession(false, Session.CLIENT_ACKNOWLEDGE);
		MessageConsumer consumer=sen.createConsumer(queue);
		
		TextMessage msg=(TextMessage) consumer.receive();
		
		System.out.println(msg.getText());
		msg.acknowledge();
		sen.close();
		con.close();
		
		

	}

}
